{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Generics.MultiRec.Languages.JSON where

import Generics.MultiRec
import Generics.MultiRec.TH.Alt

import Text.HJson

data JSON :: (* -> *) where
  TheSourceSpan :: JSON (SourceSpan)
  TheKey :: JSON Key
  TheJson :: JSON Json
  TheArray :: JSON ([] Json)
  TheObject :: JSON ([] (Key,Json))
  ThePair :: JSON (Key,Json)


$(deriveEverything
  (DerivOptions
   [ ( [t| SourceSpan |] ,"TheSourceSpan")
   , ( [t| Json |]    , "TheJson" )
   , ( [t| Key |]    , "TheKey" )
   , ( [t| [] Json |]    , "TheArray" )
   , ( [t| [] ((,) Key Json) |]    , "TheObject" )
   , ( [t| ((,) Key Json) |]    , "ThePair" )
   ]
   "JSON"
   (\t c -> "CONSTRUCTOR_" ++ t ++ "_" ++ c)
   "ThePF"
   True
   Balanced
  )
 )

type instance PF JSON = ThePF
